﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LCL.Serialization;

namespace LCL.RabbitMQ
{
    /// <summary>
    /// 发布者
    /// </summary>
    public class MqPublish<T>
    {
        public const string QueueName = "NET";
        public static IList<T> UserList = new List<T>();
        /// <summary>
        /// 添加到队列
        /// </summary>
        public static void AddQueue(T data)
        {
            //创建一个channel
            using (var channel = MqHelper.GetNewConnection().CreateModel())
            {
                //json序列化
                var bytes = SerializerFactory.Factory().Serialize<T>(data);
                channel.BasicPublish(String.Empty, QueueName, null, bytes);
            }
        }
    }
}
